<?php

/**
 * FootballFactory, Copyright Robin Loop & Pascal Wirz, 2014
 * ---
 * Template zum Editieren eines Spielers
 *
 * @author Robin
 */

require('templates/header.php');
?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <!-- JQuery -->
        <script src="../js/jquery-1.8.3.min.js"></script>
        <script src="../js/jquery-ui-1.9.2.custom.min.js"></script>
        
        <!-- JS -->
        <script src="../js/admin_menu.js"></script>
        
        <!-- CSS -->
        <link href="../css/admin.css" rel="stylesheet">
        <link href="../css/smoothness/jquery-ui-1.9.2.custom.css" rel="stylesheet">
        
    </head>

    <body>
        
        <?php include 'menu.php'; ?>
        
        <div>
            <h1>Spieler editieren: <?php echo $player->getFirstname()." ".$player->getLastname(); ?></h1>
                
            <div>
                <form action="player.php?action=save" method="post">
                    <input type="hidden" name="player_id" value="<?php echo $player->getId() ?>"/>
                    <ul>
                        <li>
                            <label for="player_firstname">Vorname</label>
                            <input type="text" name="player_firstname" placeholder="Vorname" required autofocus maxlength="255" value="<?php echo htmlspecialchars($player->getFirstname()) ?>" />
                        </li>
                        <li>
                            <label for="player_lastname">Nachname</label>
                            <input type="text" name="player_lastname" placeholder="Nachname" required maxlength="255" value="<?php echo htmlspecialchars($player->getLastname()) ?>" />
                        </li>
						<li>
							<label for="player_team">Team</label>
							<select name="player_team">
							<?php foreach ($teams as $team) { ?>
							<option value="<?php echo $team->getId(); ?>" <?php if ($team->getId() == $player->getTeam()) { echo "selected"; } else { echo ""; } ?>><?php echo $team->getName(); ?></option>
							<?php } ?>
							</select>
						</li>
						<li>
							<label for="player_seasons">Saisons</label>
							<select name="player_seasons[]" size="<?php echo $numbSeasons ?>" multiple>
							<?php foreach ($seasons as $season) { ?>
							<option value="<?php echo $season->getId(); ?>" <?php if (in_array($season->getId(), $playerSeasonList)) { echo "selected"; } else { echo ""; } ?>><?php echo $season->getName(); ?></option>
							<?php } ?>
							</select>
						</li>
                        <li>
                            <label for="player_status">Aktiv</label>
							<input type="checkbox" name="player_status" <?php if ($player->getStatus() == 1) { echo 'checked'; } else { echo ''; }  ?> />
                        </li>
                    </ul>
                    <div class="buttons">
                        <input type="submit" name="saveChanges" value="speichern" />
                        <input type="submit" formnovalidate name="cancel" value="abbrechen" />
                  </div>
                </form>
            </div>
        </div>
    
    </body>
</html>